import ajax from '@/utils/HttpUtil'
import { baseUrl as API_HOST } from '/env'

/**
 * 删除或批量删除
 * @const
 * @type {String}
 * @default  '[API_HOST]/sys/file/delete/:id'
 */
export const POST_SYS_FILE_DELETE_ID = API_HOST + '/sys/file/delete/:id'

/**
 * 删除或批量删除
 * @param {string|number} id Url参数id
 * @param {object} [data] 发送键值对数据
 * @param {object} [options] ajax参数选项
 * @returns {Promise}
 */
export function postSysFileDeleteId(id, data, options) {
  return ajax({
    method: 'post',
    params: {
      id
    },
    data: data,
    url: POST_SYS_FILE_DELETE_ID,
    ...options
  })
}

/**
 * 查询文件列表，默认查询 "安全管控清单", "规范", "超前地质预报", "课件", "法律法规"
 * @const
 * @type {String}
 * @default  '[API_HOST]/sys/file/list'
 */
export const POST_SYS_FILE_LIST = API_HOST + '/sys/file/list'

/**
 * 查询文件列表，默认查询 "安全管控清单", "规范", "超前地质预报", "课件", "法律法规"
 * @param {object} [data] 发送键值对数据
 * @param {object} [options] ajax参数选项
 * @returns {Promise}
 */
export function postSysFileList(data, options) {
  return ajax({
    method: 'post',
    data: data,
    url: POST_SYS_FILE_LIST,
    ...options
  })
}

/**
 * 根据条件查询列表
 * @const
 * @type {String}
 * @default  '[API_HOST]/sys/file/listAll'
 */
export const POST_SYS_FILE_LIST_ALL = API_HOST + '/sys/file/listAll'

/**
 * 根据条件查询列表
 * @param {object} [data] 发送键值对数据
 * @param {object} [options] ajax参数选项
 * @returns {Promise}
 */
export function postSysFileListAll(data, options) {
  return ajax({
    method: 'post',
    data: data,
    url: POST_SYS_FILE_LIST_ALL,
    ...options
  })
}

/**
 * 批量上传文件返回数量
 * @const
 * @type {String}
 * @default  '[API_HOST]/sys/file/uploadMultipleFiles'
 */
export const POST_SYS_FILE_UPLOAD_MULTIPLE_FILES = API_HOST + '/sys/file/uploadMultipleFiles'

/**
 * 批量上传文件返回数量
 * @param {object} [data] 发送键值对数据
 * @param {object} [options] ajax参数选项
 * @returns {Promise}
 */
export function postSysFileUploadMultipleFiles(data, options) {
  return ajax({
    method: 'post',
    data: data,
    url: POST_SYS_FILE_UPLOAD_MULTIPLE_FILES,
    ...options
  })
}
